package com.jieshen.lesson4;

import javax.swing.*;
import java.awt.*;

public class JframeDemo2 {
    public static void main(String[] args) {
        new MyJframe2().init();
    }

}

class MyJframe2 extends JFrame{
    public void init(){
        this.setBounds(10,10,200,300);
        this.setVisible(true);

        JLabel label = new JLabel("欢迎");
        this.add(label);

        //让文本居中
        label.setHorizontalAlignment(SwingConstants.CENTER);

        //获得容器
        Container contentPane = this.getContentPane();
        contentPane.setBackground(Color.BLUE);
    }
}